package study.ttl.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import study.ttl.entity.Carousel;
import study.ttl.mapper.CarouselMapper;
import study.ttl.service.CarouselService;

import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;



    /**
     * 添加分类
     * @param carousel
     */
    @Override
    public void add(Carousel carousel) {
        carouselMapper.insert(carousel);
    }

    /**
     * 根据id删除分类
     * @param id
     */
    @Override
    public void deleteById(Integer id) {
        carouselMapper.deleteById(id);
    }


    /**
     * 修改分类信息
     * @param carousel
     */
    @Override
    public void update(Carousel carousel) {
        carouselMapper.updateById(carousel);
    }

    /**
     * 根据id查询分类
     * @param id
     * @return
     */
    @Override
    public Carousel selectById(Integer id) {
        Carousel carousel = carouselMapper.selectById(id);
        return carousel;
    }

    /**
     * 查询所有分类
     * @return
     */
    @Override
    public List<Carousel> selectAll(Carousel carousel) {
        List<Carousel> userList = carouselMapper.selectAll(carousel);
        return userList;
    }

    /**
     * 分页查询分类
     * @param pageNum
     * @param pageSize
     * @param carousel
     * @return
     */
    @Override
    public PageInfo<Carousel> selectPage(Integer pageNum, Integer pageSize, Carousel carousel) {
        PageHelper.startPage(pageNum, pageSize);
        List<Carousel> carouselList = carouselMapper.selectAll(carousel);
        return PageInfo.of(carouselList);
    }

    /**
     * 批量删除分类
     * @param ids
     */
    @Override
    public void deleteBatch(List<Integer> ids) {
        carouselMapper.deleteBatch(ids);
    }







}
